Skip to content

Marking NobleSprite with animation dirty before drawing - #65

Open
stiv-iv wants to merge 7 commits into
NobleRobot:mainfrom
stiv-iv:main
Open

Marking NobleSprite with animation dirty before drawing#65
stiv-iv wants to merge 7 commits into
NobleRobot:mainfrom
stiv-iv:main

Conversation

@stiv-iv

@stiv-iv stiv-iv commented Nov 1, 2023

Copy link
Copy Markdown
Contributor

Fixed NobleSprite animation drawing in cases, when Graphics.sprite.getAlwaysRedraw() == false

Fixed NobleSprite animation drawing in cases, when Graphics.sprite.getAlwaysRedraw() == false
Mark sprite dirty last time in pause() and stop() methods before blocking updates.
@Mark-LaCroix Mark-LaCroix added the more info needed Further information is requested label Jun 2, 2024
@netlify

netlify Bot commented Dec 22, 2025

Copy link
Copy Markdown

Deploy Preview for cheery-choux-736619 ready!

Name Link
🔨 Latest commit 55cc344
🔍 Latest deploy log https://app.netlify.com/projects/cheery-choux-736619/deploys/6949d3581ed0120008b31a15
😎 Deploy Preview https://deploy-preview-65--cheery-choux-736619.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Igor Stepanov added 2 commits December 23, 2025 03:18
Update scene before drawing sprites
Fix NobleSprite: Dont delete coords for sprites before adding
assada added a commit to assada/NobleEngine that referenced this pull request Feb 24, 2026
assada added a commit to assada/NobleEngine that referenced this pull request Feb 24, 2026
PR NobleRobot#65 swapped the order so scene:update() runs before
Graphics.sprite.update(). This breaks scenes that draw UI elements
(Noble.Menu, Noble.Text, manual image:draw) in their update() method,
because sprite.update() redraws dirty regions on top, erasing the UI.

The markDirty() fixes from PR NobleRobot#65 in NobleSprite work correctly without
the order swap, since sprite:update() and sprite:draw() both run inside
Graphics.sprite.update().
ericlewis added a commit to ericlewis/NobleEngine that referenced this pull request Aug 11, 2026
…stream PR NobleRobot#65, adapted)

Adds a NobleSprite:update() method that calls markDirty() when the
sprite has an animation, replacing the unreliable markDirty() call
inside draw(). Also marks the sprite dirty in pause() and stop() so
the final frame renders, and NobleSprite:add() now defaults to the
sprite's current self.x/self.y instead of 0,0.

Adapted from upstream PR NobleRobot#65: the Noble.lua hunk (reordering
Graphics.sprite.update() after currentScene:update() in the game
loop) was deliberately dropped, as it would break the documented
pattern of drawing animations directly in a scene's update() method
(see Noble.Animation:draw() docs).

Co-authored-by: Igor Stepanov <stiv-iv@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ericlewis added a commit to ericlewis/NobleEngine that referenced this pull request Aug 11, 2026
Commit 75f4526 (upstream PR NobleRobot#65) moved the markDirty() call from
NobleSprite:draw() to a new NobleSprite:update() method, so that
pause() and stop() actually halt an animation. However, subclasses
that define their own update() method (the documented pattern, per
the Noble.Animation:setState usage example) shadow NobleSprite:update(),
so the sprite is never re-marked dirty and its animation freezes after
one frame when "Graphics.sprite.setAlwaysRedraw(false)" is set.

Restore a fallback markDirty() in draw(), gated on updatesEnabled(),
which preserves the pause()/stop() fix while keeping overridden
update() methods working.

Refs upstream PR NobleRobot#65.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ericlewis added a commit to ericlewis/NobleEngine that referenced this pull request Aug 11, 2026
…stream PR NobleRobot#65, adapted)

Adds a NobleSprite:update() method that calls markDirty() when the
sprite has an animation, replacing the unreliable markDirty() call
inside draw(). Also marks the sprite dirty in pause() and stop() so
the final frame renders, and NobleSprite:add() now defaults to the
sprite's current self.x/self.y instead of 0,0.

Adapted from upstream PR NobleRobot#65: the Noble.lua hunk (reordering
Graphics.sprite.update() after currentScene:update() in the game
loop) was deliberately dropped, as it would break the documented
pattern of drawing animations directly in a scene's update() method
(see Noble.Animation:draw() docs).

Co-authored-by: Igor Stepanov <stiv-iv@users.noreply.github.com>
ericlewis added a commit to ericlewis/NobleEngine that referenced this pull request Aug 11, 2026
Commit 75f4526 (upstream PR NobleRobot#65) moved the markDirty() call from
NobleSprite:draw() to a new NobleSprite:update() method, so that
pause() and stop() actually halt an animation. However, subclasses
that define their own update() method (the documented pattern, per
the Noble.Animation:setState usage example) shadow NobleSprite:update(),
so the sprite is never re-marked dirty and its animation freezes after
one frame when "Graphics.sprite.setAlwaysRedraw(false)" is set.

Restore a fallback markDirty() in draw(), gated on updatesEnabled(),
which preserves the pause()/stop() fix while keeping overridden
update() methods working.

Refs upstream PR NobleRobot#65.
@ericlewis

Copy link
Copy Markdown

I integrated this locally — the sprite-side changes are a real fix (pause()/stop() actually halt the animation now), but I found two issues worth flagging:

  1. The Noble.lua reorder breaks drawing from a scene's update(). Moving Graphics.sprite.update() after currentScene:update() means sprite and background rendering paint over anything drawn directly in update() — which is a documented pattern (the Noble.Animation:draw() docs show calling it from a scene's update() method). The sprite-side changes work without this hunk: NobleSprite:update() runs inside Graphics.sprite.update(), and a markDirty() there still takes effect in the same frame's draw pass.

  2. Subclasses that override update() lose the dirty-marking. With markDirty() moved from draw() into NobleSprite:update(), a subclass that defines its own update() (also a documented pattern — see the Noble.Animation:setState usage example) shadows it, so under Graphics.sprite.setAlwaysRedraw(false) the animation freezes after one frame. A fallback in draw(), gated on updatesEnabled(), preserves the pause()/stop() fix while keeping overridden update() methods working:

function NobleSprite:draw()
	if (self.animation ~= nil) then
		self.animation:draw()
		if (self:updatesEnabled()) then
			-- Normally NobleSprite:update() marks this sprite dirty each frame.
			-- Also mark it here, in case a subclass has overridden update()
			-- without calling its super method.
			self:markDirty()
		end
	end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

more info needed Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants